#!/bin/bash
ports=$1
cat>acheck_port_tomcat<<EOF
#!/bin/bash
echo '<<<tomcat>>>'
EOF



i=0
for port in ${ports}
do

OLD_IFS="$IFS"
IFS=":"
arr=($port)
IFS="$OLD_IFS"

name=${arr[0]}
realPort=${arr[1]}

#dot='-'
#service='flexweb'
#cluster='tomcat'
#i=$(( $i + 1 ))
#name=$service$dot$cluster$dot$i
cat<<EOF>>acheck_port_tomcat
#pid=\`netstat -ntlp | grep $port|awk '{printf \$7}'|cut -d/ -f1\`
pstxt=\`ps aux|grep ${realPort} |grep "java"|grep -v "grep"|awk '{print "CPU "\$3" MEM "\$4" RSS "\$6}'\`
echo $name \${pstxt}
EOF
done

chmod 744 acheck_port_tomcat
